package com.game.jumper.activity;

import net.youmi.android.AdManager;
import net.youmi.android.banner.AdSize;
import net.youmi.android.banner.AdView;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.example.jumperball.R;

public class MainActivity extends Activity
{

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);

		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
				, WindowManager.LayoutParams.FLAG_FULLSCREEN);  
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);  
		// setContentView(R.layout.activity_main);

		setContentView(new MySurfaceView(this));

		// 加载广告
		AdManager.getInstance(this).init(
				"df4c0fbfafa6db94", "29a938ad9240df45", false);

		// 实例化 LayoutParams（重要）
		FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
				FrameLayout.LayoutParams.FILL_PARENT,
				FrameLayout.LayoutParams.WRAP_CONTENT);

		// 设置广告条的悬浮位置
		layoutParams.gravity = Gravity.TOP | Gravity.RIGHT; // 这里示例为右下角
		// 实例化广告条
		AdView adView = new AdView(this, AdSize.FIT_SCREEN);
		// 调用 Activity 的 addContentView 函数
		// this.addContentView(adView, layoutParams);
		 this.addContentView(adView, layoutParams);
		 this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		
		
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		//getMenuInflater().inflate(R.menu.main, menu);
		menu.add(0, 1, 1, "关于").setIcon(R.drawable.jumperballlogo);
		return true;
	}
	  public boolean onOptionsItemSelected(MenuItem item) {
		  if(item.getGroupId()==0){
		  new AlertDialog.Builder(this)  
		                  .setTitle("6425工作室")
		                  .setMessage("欢迎您提出宝贵的意见和建议，发送邮件至weilaizhimen@126.com")
		                  .setPositiveButton("确定", null)
		                  .show();
		  
		  }
	        return true; 
	    }

	@Override
	public boolean onTouchEvent(MotionEvent event)
	{
		if (event.getAction() == MotionEvent.ACTION_DOWN)
		{

			Intent in = new Intent(MainActivity.this, PlayLG.class);
			startActivityForResult(in, 0);
		}
		return true;
	}


	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		//this.finish();
	}


	

}
